﻿using Authorization.Entitys;
using Authorization.IRepository;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Authorization.Repository
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly Naruto.Repository.UnitOfWork.IUnitOfWork unitOfWork;

        public UnitOfWork(Naruto.Repository.UnitOfWork.IUnitOfWork<AspNetIdentityDbContext> _unitOfWork)
        {
            unitOfWork = _unitOfWork;
        }
        public async Task BeginTransactionAsync(CancellationToken cancellationToken = default)
        {
            await unitOfWork.BeginTransactionAsync(cancellationToken);
        }

        public async Task CommitTransactionAsync(CancellationToken cancellationToken = default)
        {
            await unitOfWork.CommitTransactionAsync(cancellationToken);
        }

        public async Task RollBackTransactionAsync(CancellationToken cancellationToken = default)
        {
            await unitOfWork.RollBackTransactionAsync(cancellationToken);
        }

        public async Task<int> SaveChangeAsync(CancellationToken cancellationToken = default)
        {
            return await unitOfWork.SaveChangeAsync(cancellationToken);
        }
    }
}
